home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX Patches 1995 March
/
SGI IRIX Patches 1995 Mar.iso
/
5.2_patches
/
patchSG0000226
/
patchSG0000226.idb
/
usr
/
include
/
sys
/
ktime.h.z
/
ktime.h
Wrap
C/C++ Source or Header
|
1995-03-10
|
6KB
|
220 lines
/**************************************************************************
* *
* Copyright (C) 1989-1992 Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
#ifndef _SYS_KTIME_H
#define _SYS_KTIME_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* This header contains internal kernel time handling data structures
* Do not use __mips macro here
* Use ONLY definitions that are constant whether compiled mips2 or 3
*/
/*
* IRIX4 versions of time interface structures
*
* IRIX4 and 5 timevals and itimervals are the same
* IRIX4 has no timestruc
*/
/*
* IRIX5/Mips ABI versions of time interface structures
*/
typedef struct irix5_timestruc {
app32_long_t tv_sec;
app32_long_t tv_nsec;
} irix5_timestruc_t;
struct irix5_timeval {
app32_long_t tv_sec; /* seconds */
app32_long_t tv_usec; /* and microseconds */
};
struct irix5_itimerval {
struct irix5_timeval it_interval; /* timer interval */
struct irix5_timeval it_value; /* current value */
};
#define timestruc_to_irix5(t,i5) \
(i5)->tv_sec = (t)->tv_sec; \
(i5)->tv_nsec = (t)->tv_nsec;
#define timeval_to_irix5(t,i5) \
(i5)->tv_sec = (t)->tv_sec; \
(i5)->tv_usec = (t)->tv_usec;
#define irix5_to_timeval(t,i5) \
(t)->tv_sec = (i5)->tv_sec; \
(t)->tv_usec = (i5)->tv_usec;
typedef app32_long_t irix5_time_t;
/*
* IRIX5_64 versions of time interface structures
*/
typedef struct irix5_64_timestruc {
app64_long_t tv_sec;
app64_long_t tv_nsec;
} irix5_64_timestruc_t;
struct irix5_64_timeval {
app64_long_t tv_sec; /* seconds */
app64_long_t tv_usec; /* and microseconds */
};
struct irix5_64_itimerval {
struct irix5_64_timeval it_interval; /* timer interval */
struct irix5_64_timeval it_value; /* current value */
};
#define timestruc_to_irix5_64(t,i5_64) \
(i5_64)->tv_sec = (t)->tv_sec; \
(i5_64)->tv_nsec = (t)->tv_nsec;
#define timeval_to_irix5_64(t,i5_64) \
(i5_64)->tv_sec = (t)->tv_sec; \
(i5_64)->tv_usec = (t)->tv_usec;
typedef app64_long_t irix5_64_time_t;
/*
* Internal kernel versions of time structures
* Kernel should use the irix* structures for system call interfaceing
* Kernel uses the user definitions of timestruc, timeval and itimerval
* internally - these will change size in 64 bit mode but that
* shouldn't matter (but proc and user will chg size!)
*/
#ifdef NOTUSED
typedef struct ktimestruc {
__int32_t tv_sec;
__int32_t tv_nsec;
} ktimestruc_t;
struct ktimeval {
__int32_t tv_sec; /* seconds */
__int32_t tv_usec; /* and microseconds */
};
struct kitimerval {
struct ktimeval it_interval; /* timer interval */
struct ktimeval it_value; /* current value */
};
#endif
#define USEC_PER_SEC 1000000 /* number of usecs for 1 second */
#define NSEC_PER_SEC 1000000000 /* number of nsecs for 1 second */
#define USEC_PER_TICK (USEC_PER_SEC/HZ)
#define NSEC_PER_TICK (NSEC_PER_SEC/HZ)
/* has to be rt process, plus not multiple of 10ms */
#define need_fastimer(tvp, pp) ((pp->p_rtpri >= NDPHIMAX && \
pp->p_rtpri <= ndpri_lolim) && \
(tvp)->tv_usec != 0 && \
( ((tvp)->tv_usec < USEC_PER_TICK) || \
((tvp)->tv_usec % USEC_PER_TICK) != 0 ))
/*
* Macro to round usec to sec in time timeval structure.
* We even go so far as to loop decrementing usec and adding to
* seconds until usec < sec.
*/
#define RNDTIMVAL(t) \
{ \
register struct timeval *tp = (t); \
\
while ( tp->tv_usec >= USEC_PER_SEC ) \
{ \
tp->tv_usec -= USEC_PER_SEC; \
tp->tv_sec++; \
} \
}
#define RND_TIMESTRUC_VAL(t) \
{ \
register timestruc_t *tp = (t); \
\
while ( tp->tv_nsec >= NSEC_PER_SEC ) \
{ \
tp->tv_nsec -= NSEC_PER_SEC; \
tp->tv_sec++; \
} \
}
/*
* macros to convert from timestruc to timeval and vice-versa
*/
#define TIMESTRUC_TO_TIMEVAL(ts, tv) \
{ \
(tv)->tv_sec = (ts)->tv_sec; \
(tv)->tv_usec = (ts)->tv_nsec/1000; \
}
#define TIMEVAL_TO_TIMESTRUC(tv, ts) \
{ \
(ts)->tv_sec = (tv)->tv_sec; \
(ts)->tv_nsec = (tv)->tv_usec*1000; \
}
struct proc;
struct eframe_s;
struct rusage;
struct timestruc;
struct timeval;
extern void realitexpire(struct proc *);
extern void ticks_to_nanosecs(time_t, struct timestruc *);
extern long doadjtime(long);
extern void nanotime(struct timestruc *);
extern void microtime(struct timeval *);
extern void tick_to_timeval(int, struct timeval *, int);
extern time_t fasthzto(struct timeval *);
extern time_t hzto(struct timeval *);
extern time_t timestruc_to_ticks(struct timestruc *);
extern void timevalfix(struct timeval *);
extern void timevalsub(struct timeval *, struct timeval *);
extern void timevaladd(struct timeval *, struct timeval *);
extern int itimerfix(struct timeval *);
extern int itimerdecr(register struct itimerval *, int);
extern void timestruc_add(struct timestruc *, struct timestruc *);
extern void timestruc_fix(struct timestruc *);
extern __psint_t query_cyclecntr(uint *);
extern int chktimeout_tick(int, void (*)(), void *);
extern void ackrtclock(void);
extern void bump_leds(void);
extern int loclkok(struct eframe_s *);
extern int set_timer_intr(processorid_t, long);
extern void settime(long, long);
extern void wtodc(void);
extern void ru_timecal(struct proc *, struct rusage *);
extern void enable_fastclock(void);
extern int dosetitimer(int, struct itimerval *, struct itimerval *);
extern time_t get_realtime_ticks(void);
extern int callout_time_to_hz(int, int);
extern int settimetrim(int);
extern int gettimetrim(void);
#if _K64U64
enum xlate_mode;
struct xlate_info_s;
extern int irix5_to_timeval_xlate(enum xlate_mode, void *,
int, struct xlate_info_s *);
extern int timeval_to_irix5_xlate(void *, int, struct xlate_info_s *);
#endif
#ifdef __cplusplus
}
#endif
#endif /* _SYS_KTIME_H */